import { Routes } from '@angular/router';
import { startPageGuard } from '@core';
import { authSimpleCanActivate, authSimpleCanActivateChild } from '@delon/auth';

import { LayoutBasicComponent } from '../layout';
import { ProfileBaseComponent } from './system/account/base/base.component';
import { ProfileComponent } from './system/account/profile.component';
import { ProfileSecurityComponent } from './system/account/security/security.component';
import { UserConsentComponent } from './system/account/security/user-consent.component';

export const routes: Routes = [
  {
    path: '',
    component: LayoutBasicComponent,
    canActivate: [startPageGuard, authSimpleCanActivate],
    canActivateChild: [authSimpleCanActivateChild],
    data: {},
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      {
        path: 'dashboard',
        loadChildren: () => import('./dashboard/routes').then(m => m.routes)
      },
      {
        path: 'profile',
        component: ProfileComponent,
        children: [
          { path: '', redirectTo: 'base', pathMatch: 'full' },
          { path: 'base', component: ProfileBaseComponent, data: { title: '基本设置' } },
          { path: 'security', component: ProfileSecurityComponent, data: { title: '安全设置' } },
          { path: 'consent', component: UserConsentComponent, data: { title: '授权信息' } }
        ]
      },
      // 系统监控
      { path: 'monitor', loadChildren: () => import('./monitor/routes').then(m => m.routes) },
      // 系统管理
      { path: 'system', loadChildren: () => import('./system/routes').then(m => m.routes) },
      // 系统管理
      { path: 'oauth', loadChildren: () => import('./oauth2/routes').then(m => m.routes) }
    ]
  },
  // passport
  { path: '', loadChildren: () => import('./passport/routes').then(m => m.routes) },
  { path: 'exception', loadChildren: () => import('./exception/routes').then(m => m.routes) },
  { path: '**', redirectTo: 'exception/404' }
];
